<html>
<head><meta charset="utf-8"><title>Dynamically moving flycheck diagnostics · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html">Dynamically moving flycheck diagnostics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="219079242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219079242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219079242">(Dec 07 2020 at 13:30)</a>:</h4>
<p>I was looking into automatically moving flycheck diagnostics around when the containing file is edited, but this seems like a fairly nontrivial algorithm to implement. Is there an existing implementation or algorithm description of something like this that I could look at?</p>



<a name="219079324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219079324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219079324">(Dec 07 2020 at 13:31)</a>:</h4>
<p>I feel pretty strongly that this should be handled by the editor</p>



<a name="219079450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219079450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219079450">(Dec 07 2020 at 13:32)</a>:</h4>
<p>It can adjust ranges synchronously, and it doesn't need any langauge-specific info for that. </p>
<p>I wonder if non-VS clients do this?</p>



<a name="219079538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219079538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219079538">(Dec 07 2020 at 13:33)</a>:</h4>
<p>Yeah, but I don't think any of them actually do this</p>



<a name="219079559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219079559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219079559">(Dec 07 2020 at 13:33)</a>:</h4>
<p>VS Code also doesn't</p>



<a name="219079906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219079906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219079906">(Dec 07 2020 at 13:36)</a>:</h4>
<p>Yeah... I think this is the case where it's better to not solve a problem at all, than to solve it in a wrong way.</p>



<a name="219079947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219079947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219079947">(Dec 07 2020 at 13:36)</a>:</h4>
<p>By making range updating "async" we kind of loose any hope to have consistent results</p>



<a name="219080000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219080000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219080000">(Dec 07 2020 at 13:37)</a>:</h4>
<p>Clients, on the other hand, can adjust ranges in lockstep with updating the text buffer (whcih they do anyway for, eg, syntax highlighting)</p>



<a name="219080183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219080183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219080183">(Dec 07 2020 at 13:39)</a>:</h4>
<p>that said, synchronization concerns aside, this shouldn't be hard at the core</p>



<a name="219080211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219080211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219080211">(Dec 07 2020 at 13:39)</a>:</h4>
<p>See <code>TextEdit::apply_to_offset</code></p>



<a name="219080352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219080352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219080352">(Dec 07 2020 at 13:40)</a>:</h4>
<p>(plus, there should be additional handling for "sticky" span edges. For highlighting, you, eg, want to extend the span of idenifier if a user types next to it)</p>



<a name="219080621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219080621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219080621">(Dec 07 2020 at 13:43)</a>:</h4>
<p>I remember seeing something about moving to a pull model for diagnostics. If a server switched to that it might be easier to get the right logic into the client</p>



<a name="219081108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219081108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219081108">(Dec 07 2020 at 13:47)</a>:</h4>
<p>riiiight, there's also protocol-level concern that both edits and diagnostics are notifications (going in the opposite directions), so it's actually impossible to order them</p>



<a name="219081146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219081146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219081146">(Dec 07 2020 at 13:47)</a>:</h4>
<p>(although document version might be enough for this particular case of shifting edits)</p>



<a name="219082099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219082099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219082099">(Dec 07 2020 at 13:56)</a>:</h4>
<p>hm. <em>can</em> the editor do this for the check-based diagnostics though? just from how emacs behaves, it looks to me like we are sending the diagnostics with the wrong range if the user edits without saving (i.e. we're sending the old check diagnostics with the now-stale ranges again?)</p>



<a name="219082465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219082465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219082465">(Dec 07 2020 at 13:59)</a>:</h4>
<p>Hm, I think that would be a different problem? Basically, we compute just the wrong diagnostics in this case (not only the ranges), and we should force client to save documents when computing diagnostics</p>



<a name="219082550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219082550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219082550">(Dec 07 2020 at 14:00)</a>:</h4>
<p>well I mean our internal diagnostics are correct and move correctly, because they use the unsaved document</p>



<a name="219082611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219082611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219082611">(Dec 07 2020 at 14:00)</a>:</h4>
<p>hmm, and if we publish internal diagnostics only, that would override the check diagnostics</p>



<a name="219082630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219082630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219082630">(Dec 07 2020 at 14:01)</a>:</h4>
<p>Emacs doesn't move diagnostics at all by the way, it just hides all diagnostics as soon as you type and displays the new ones once they arrive</p>



<a name="219083422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083422">(Dec 07 2020 at 14:07)</a>:</h4>
<p>LSP issue for pull model: <a href="https://github.com/microsoft/language-server-protocol/issues/737">https://github.com/microsoft/language-server-protocol/issues/737</a>. It looks like this is an issue about interactive diagnostics for vscode: <a href="https://github.com/microsoft/vscode/issues/103953">https://github.com/microsoft/vscode/issues/103953</a></p>



<a name="219083687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083687">(Dec 07 2020 at 14:10)</a>:</h4>
<p>Isn't the push model much better suited for... everything? If the client has to pull it might not update when eg. an import now resolved because a different file changed</p>



<a name="219083703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083703">(Dec 07 2020 at 14:10)</a>:</h4>
<p>This is also a problem for semantic tokens, I think</p>



<a name="219083809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083809">(Dec 07 2020 at 14:11)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> I still believe that the right model here is that of dart analysis server</p>



<a name="219083844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083844">(Dec 07 2020 at 14:11)</a>:</h4>
<p><a href="https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/doc/api.html#request_analysis.setSubscriptions">https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/doc/api.html#request_analysis.setSubscriptions</a></p>



<a name="219083847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083847">(Dec 07 2020 at 14:11)</a>:</h4>
<p>push + subscriptions? yeah</p>



<a name="219083868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083868">(Dec 07 2020 at 14:11)</a>:</h4>
<p>yup, that one</p>



<a name="219083931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219083931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219083931">(Dec 07 2020 at 14:12)</a>:</h4>
<p>And also requiring replies for changes notification, so that the client knows what state of the world the serve sees</p>



<a name="219085423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219085423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219085423">(Dec 07 2020 at 14:25)</a>:</h4>
<p>Does the dart LSP stack use the subscription model? I've used their stuff on vscode for some flutter work and it's pretty slick.</p>



<a name="219085557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Dynamically%20moving%20flycheck%20diagnostics/near/219085557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Dynamically.20moving.20flycheck.20diagnostics.html#219085557">(Dec 07 2020 at 14:26)</a>:</h4>
<p>I don't know</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>